package com.JFapp.controller;

import com.JFapp.domain.dto.TagDto;
import com.JFapp.domain.dto.TagListDto;
import com.JFapp.domain.entity.ResponseResult;
import com.JFapp.domain.entity.Tag;
import com.JFapp.service.TagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/content/tag")
@Api("标签管理")
public class TagController {


    @Autowired
    private TagService tagService;
    @GetMapping("/list")
    @ApiOperation("查询标签")
    public ResponseResult list(Integer pageNum, Integer pageSize, TagListDto tagListDto){
        ResponseResult result=tagService.selectTagList(pageNum,pageSize,tagListDto);
        return result;
    }

    @GetMapping("/listAllTag")
    @ApiOperation("查询标签")
    public ResponseResult listAllTag(){
        return tagService.selectALLTagList();
    }

    @ApiOperation("添加标签")
    @PostMapping
    public ResponseResult addTag(@RequestBody TagListDto tagListDto){
        return tagService.addTag(tagListDto);
    }

    @ApiOperation("查询标签详细")
    @GetMapping("/{id}")
    public  ResponseResult getTagDetail(@PathVariable Long id){
        return ResponseResult.okResult(tagService.getById(id));
    }
    @PostMapping("修改标签")
    @PutMapping()
    public ResponseResult updateTag(@RequestBody TagDto tag){
        return tagService.updateTag(tag);
    }

}
